package net.minecraft.src;

public class ModelDragonfly extends ModelBase
{
	public ModelDragonfly()
	{
		tailPart = new ModelRenderer(this, 10, 0);
		tailPart.addBox(0F, 0F, 0F, 2, 1, 2);
		tailPart.setRotationPoint(0.4666667F, 0F, 4F);
		tailPart.rotateAngleX = 0F;
		tailPart.rotateAngleY = 0F;
		tailPart.rotateAngleZ = 0F;
		tailPart.mirror = false;
		tailPart2 = new ModelRenderer(this, 18, 0);
		tailPart2.addBox(0F, 0F, 0F, 2, 1, 2);
		tailPart2.setRotationPoint(0.5F, 0F, 6F);
		tailPart2.rotateAngleX = -0.22307F;
		tailPart2.rotateAngleY = 0F;
		tailPart2.rotateAngleZ = 0F;
		tailPart2.mirror = false;
		tailPart3 = new ModelRenderer(this, 27, 0);
		tailPart3.addBox(0F, 0F, 0F, 2, 1, 2);
		tailPart3.setRotationPoint(0.5F, 0.5F, 8F);
		tailPart3.rotateAngleX = -0.44614F;
		tailPart3.rotateAngleY = 0F;
		tailPart3.rotateAngleZ = 0F;
		tailPart3.mirror = false;
		tailPart4 = new ModelRenderer(this, 36, 0);
		tailPart4.addBox(0F, 0F, 0F, 1, 1, 2);
		tailPart4.setRotationPoint(1F, 1.5F, 9.8F);
		tailPart4.rotateAngleX = -0.66922F;
		tailPart4.rotateAngleY = 0F;
		tailPart4.rotateAngleZ = 0F;
		tailPart4.mirror = false;
		head = new ModelRenderer(this, 0, 0);
		head.addBox(0F, 0F, 0F, 3, 2, 2);
		head.setRotationPoint(0F, 0.2F, -1F);
		head.rotateAngleX = 0.18589F;
		head.rotateAngleY = 0F;
		head.rotateAngleZ = 0F;
		head.mirror = false;
		body = new ModelRenderer(this, 0, 4);
		body.addBox(0F, 0F, 0F, 3, 2, 3);
		body.setRotationPoint(0F, 0F, 1F);
		body.rotateAngleX = 0F;
		body.rotateAngleY = 0F;
		body.rotateAngleZ = 0F;
		body.mirror = false;
		tailOuterRight = new ModelRenderer(this, 48, 0);
		tailOuterRight.addBox(0F, 0F, 0F, 0, 1, 2);
		tailOuterRight.setRotationPoint(0.91F, 2.533333F, 11F);
		tailOuterRight.rotateAngleX = -0.89229F;
		tailOuterRight.rotateAngleY = 0F;
		tailOuterRight.rotateAngleZ = 0F;
		tailOuterRight.mirror = false;
		tailOuterLeft = new ModelRenderer(this, 43, 0);
		tailOuterLeft.addBox(0F, 0F, 0F, 0, 1, 2);
		tailOuterLeft.setRotationPoint(2F, 2.5F, 11F);
		tailOuterLeft.rotateAngleX = -0.89229F;
		tailOuterLeft.rotateAngleY = 0F;
		tailOuterLeft.rotateAngleZ = 0F;
		tailOuterLeft.mirror = false;
		leftWingLower = new ModelRenderer(this, 0, 10);
		leftWingLower.addBox(0F, 0F, 0F, 5, 1, 2);
		leftWingLower.setRotationPoint(3F, 0.1F, 2F);
		leftWingLower.rotateAngleX = 0F;
		leftWingLower.rotateAngleY = 0F;
		leftWingLower.rotateAngleZ = 0F;
		leftWingLower.mirror = false;
		leftWingUpper = new ModelRenderer(this, 15, 10);
		leftWingUpper.addBox(0F, 0F, 0F, 8, 1, 2);
		leftWingUpper.setRotationPoint(2F, 0.1F, 1F);
		leftWingUpper.rotateAngleX = -0.14871F;
		leftWingUpper.rotateAngleY = 0.18589F;
		leftWingUpper.rotateAngleZ = -0.11154F;
		leftWingUpper.mirror = false;
		rightWingLower = new ModelRenderer(this, 0, 14);
		rightWingLower.addBox(-5F, 0F, 0F, 5, 1, 2);
		rightWingLower.setRotationPoint(0, 0F, 2F);
		rightWingLower.rotateAngleX = 0F;
		rightWingLower.rotateAngleY = 0F;
		rightWingLower.rotateAngleZ = 0F;
		rightWingLower.mirror = false;
		rightWingUpper = new ModelRenderer(this, 15, 14);
		rightWingUpper.addBox(0F, 0F, 0F, 8, 1, 2);
        rightWingUpper.setRotationPoint(0.5F, 0.6F, 3F);
        rightWingUpper.rotateAngleX = 0.24335F;
        rightWingUpper.rotateAngleY = 2.91728F;
        rightWingUpper.rotateAngleZ = -0.09563F;
        rightWingUpper.mirror = false;
	}

	public void setLivingAnimations(EntityLiving entityliving, float f, float f1, float f2)
	{
		EntityDragonfly df = (EntityDragonfly) entityliving;
		updateWings(df);
		flexTail(df);
	}
	
	private void flexTail(EntityDragonfly df)
	{
		if(df.isFlappingWings())
		{
			df.tailState += 0.5F;
			if(df.tailState > 5)
				df.tailState = 5;
		}
		else
		{
			df.tailState -= 0.5F;
			if(df.tailState < 0)
				df.tailState = 0;
		}
		tailPart.rotationPointY = 0F + (0.0F * df.tailState);
		tailPart.rotateAngleX = 0F + (0.0F * df.tailState);
		tailPart2.rotationPointY = 0F + (0.010F * df.tailState);
		tailPart2.rotateAngleX = -0.22307F + (0.03F * df.tailState);
		tailPart3.rotationPointY = 0.5F - (0.060F * df.tailState);
		tailPart3.rotateAngleX = -0.44614F + (0.050F * df.tailState);
		tailPart4.rotationPointY = 1.5F - (0.200F * df.tailState);
		tailPart4.rotateAngleX = -0.66922F + (0.050F * df.tailState);
		tailOuterRight.rotationPointY = 2.533333F - (0.300F * df.tailState);
		tailOuterRight.rotateAngleX = -0.89229F + (0.050F * df.tailState);
		tailOuterLeft.rotationPointY = 2.5F - (0.300F * df.tailState);
		tailOuterLeft.rotateAngleX = -0.89229F + (0.050F * df.tailState);
	}
	
	private void updateWings(EntityDragonfly df)
	{
		if(df.isFlappingWings())
		{
			++df.wingState;
			if(++df.wingState >= 10)
				df.wingState = -10;
		}
		else
			df.wingState = 0;
		float offset = df.wingState * 0.1F;
		leftWingLower.rotateAngleZ = 0F + offset;
		leftWingUpper.rotateAngleZ = -0.11154F + offset;
		rightWingLower.rotateAngleZ = 0F - offset;
		rightWingUpper.rotateAngleZ = 0.14871F - offset;
	}

	public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
	{
		super.render(entity, f, f1, f2, f3, f4, f5);
		setRotationAngles(f, f1, f2, f3, f4, f5);
		tailPart.render(f5);
		tailPart2.render(f5);
		tailPart3.render(f5);
		tailPart4.render(f5);
		head.render(f5);
		body.render(f5);
		tailOuterRight.render(f5);
		tailOuterLeft.render(f5);
		leftWingLower.render(f5);
		leftWingUpper.render(f5);
		rightWingLower.render(f5);
		rightWingUpper.render(f5);
	}

	public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
	{
		super.setRotationAngles(f, f1, f2, f3, f4, f5);
	}

	/* Model */
	ModelRenderer tailPart;
	ModelRenderer tailPart2;
	ModelRenderer tailPart3;
	ModelRenderer tailPart4;
	ModelRenderer head;
	ModelRenderer body;
	ModelRenderer tailOuterRight;
	ModelRenderer tailOuterLeft;
	ModelRenderer leftWingLower;
	ModelRenderer leftWingUpper;
	ModelRenderer rightWingLower;
	ModelRenderer rightWingUpper;
}
